package com.doyutu.seed.config.shiro;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author DoyuTu
 * @version 0.0.1 spring-boot-project-seed
 */
@Component
public class RedisCacheManager implements CacheManager {

  @Autowired
  @Qualifier("shiroRedisTemplate")
  private RedisTemplate<String, Object> redisTemplate;

  @Override
  public <K, V> Cache<K, V> getCache(String name) throws CacheException {
    return new RedisCache<>(name, redisTemplate);
  }

}
